package com.xhs.service.impl;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @desc: 使用线程池Executor框架创建线程
 * @projectName: tools-parent
 * @author: xhs
 * @date: 2022/12/5 21:30
 * @version: JDK 1.8
 */
@Slf4j
public class Thread6ServiceImpl {

    public static void main(String[] args) {
        log.info(">>>>>>>>>>>>>>使用线程池Executor框架创建线程,我是主线程:{}<<<<<<<<<<<<<<<<<<<<", Thread.currentThread().getName());
        ExecutorService executorService = Executors.newCachedThreadPool();
        executorService.execute(new Runnable() {
            @Override
            public void run() {
                log.info(">>>>>>>>>>>>>>使用线程池Executor框架创建线程,我是子线程:{}<<<<<<<<<<<<<<<<<<<<", Thread.currentThread().getName());
            }
        });
        log.info(">>>>>>>>>>>>>>使用线程池Executor框架创建线程,我是主线程:{}<<<<<<<<<<<<<<<<<<<<", Thread.currentThread().getName());
    }
}
